#include <iostream>
#include <map>
#include <sstream>
#include <vector>

int main()
{
    std::string istr;
    std::getline(std::cin, istr);
    int num;
    std::cin >> num;

    int i = 0;
    std::istringstream iss(istr);
    std::map<int, std::vector<int>> step_map;
    int tmp;
    while (iss >> tmp)
    {
        step_map[tmp].push_back(i);
        i++;
    }

    std::pair<int, int> min_pair(1e9, 1e9);
    int min_ids = 1e9;
    for (auto it = step_map.begin(); it != step_map.end(); it++)
    {
        int res = num - it->first;
        auto fit = step_map.find(res);
        if (fit != step_map.end())
        {
            int id1 = it->second[0];
            int id2 = fit->second[0];
            if (min_ids > id1 + id2)
            {
                min_ids = id1 + id2;
                min_pair.first = id1 < id2 ? it->first : fit->first;
                min_pair.second = id1 > id2 ? it->first : fit->first;
            }
        }
    }

    std::cout << min_pair.first << "," << min_pair.second << std::endl;

    return 0;
}